import React from "react";
import Translate, { useTranslation } from "i18n-react-json";

import zh from './locales/zh.json'
import en from './locales/en.json'

const locales = {
  zh, en
}

const i18n = new Translate(locales);
i18n.setLocale("en");

const App1 = () => {
  const { t } = useTranslation()
  return <div>
    <div>切换</div>
    <button onClick={() =>i18n.locale = 'zh'}>中文</button>
    <button onClick={() =>i18n.locale = "en" }>英文</button>
    <div>{ t('title') }</div>
  </div>;
};

export default App1;
